{extend name="common/menu_child" /}

{block name="nav"}
<span class="layui-breadcrumb">
	<a>资源回收订单</a>
	<a href="{:url('index')}">长期订单列表</a>
	<a><cite>子订单列表</cite></a>
</span>
{/block}

{block name="body"}
<div class="layui-row">
	<form class="layui-form layui-col-md12 x-so">
		<div class="layui-input-inline">
            <select name="status">
				<option value="">状态</option>
				{foreach name="status" item="vo" key="ko"}<option value="{$ko}" {heq name="condition.status" value="$ko"}selected{/heq}>状态：{$vo}</option>{/foreach}
			</select>
		</div>
		<input class="layui-input" placeholder="订单编号" name="number" value="{$condition.number}" />
		<input class="layui-input" placeholder="工作人员" name="staff_realname" value="{$condition.staff_realname}" />
		<input style="display:none;" name="p" value="1" />
		<button class="layui-btn"><i class="layui-icon">&#xe615;</i></button>
	</form>
</div>
<table class="layui-table">
	<thead>
		<tr>
			<th>序号</th>
			<th>订单编号</th>
			<th>预约时间</th>
			<th>状态</th>
			<th>工作人员</th>
			<th>添加时间</th>
			<th>操作</th>
		</tr>
	</thead>
	<tbody>
		{eq name="data_list|count" value="0"}
			<tr>
				<td colspan="20">暂无数据</td>
			</tr>
		{else/}
			{foreach name="data_list" item="vo" key="ko"}
			<tr>
				<td>{$ko + 1}</td>
				<td>{$vo.identifier}</td>
				<td>{$vo.action_date|date='Y-m-d',###}&nbsp;{$vo.action_time}</td>
				<td>{$vo.status_string}</td>
				<td>{$vo.staff_realname}</td>
				<td>{$vo.create_time|date='Y-m-d H:i:s',###}</td>
				<td class="td-manage">
					{eq name="vo.can_cancel" value="true"}
					<a title="取消订单" bind-name="del" data-id="{$vo.id}" href="javascript:void(0);" onclick="javascript:order_cancel({$vo.id});">
						<i class="layui-icon" style="font-size:18px;">&#xe64d;</i>
					</a>
					{/eq}
				</td>
			</tr>
			{/foreach}
		{/eq}
	</tbody>
</table>

<div class="page">{$page}</div>

<div class="window_content" name="order_cancel" style="display:none;">
	<form class="layui-form" style="margin:20px 20px 10px 20px;">
		<div class="layui-form-item layui-form-text">
			<textarea name="cause" placeholder="请输入取消原因" class="layui-textarea"></textarea>
		</div>
	</form>
</div>
{/block}

{block name="javascript"}
<script type="text/javascript">
	
	function order_cancel(order_id) {
		let content = $('div.window_content[name=order_cancel]').clone();
		$(content).children('form.layui-form').attr('name', 'order_cancel');
		layer.open({
			type: 1,
			title: '取消订单',
			content: $(content).html(),
			area: ['400px'],
			btn: ['确定', '取消'],
			yes: function(){
				
				let data = disposeFormSerialize('form.layui-form[name=order_cancel]');
				data.id = order_id;
				
				action_post_json('{:url("recycle_order/cancel")}', data, function(response){
					layer.msg(response.message);
					if(0 === response.errno){
						setTimeout('window.location.reload()', 1000);
					};
				});
				
			}
		});
	};
	
</script>
{/block}